-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add new command to send test data to Observe #113
Conversation
const TestDataPath = "/observe-agent/test" | ||
|
||
var defaultTestData = map[string]any{ | ||
"hello": "world", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these defaults okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes totally ok
"github.com/spf13/cobra" | ||
) | ||
|
||
const TestDataPath = "/observe-agent/test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curl https://175914298205.collect.observe-eng.com/v1/http \
-H "Authorization: Bearer $TOKEN" \
-H "Content-type: application/json" \
-d '{"data": "hello world"}'
request should look like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is how the POST request is structured, but I was getting a path
item of "/"
in extra
even when not specifying a path, so I added this for clarity. You can see my example screenshot in the PR description. Lmk if there's a way to exclude the extra
all together! I couldn't find it in our docs though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully the test I added can clarify this! If not, I might be misunderstanding your request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you are sending to https://observe-agent/test/ , I think maybe Alex meant that you can send the testdata to a hardcoded collect path of that specific test customer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this to extra path; the post is being made to eg. https://175914298205.collect.observe-eng.com/v1/http/observe-agent/test
. In our http API, it seems that you always get a field in the extra
data with the path that comes after /v1/http
, so I wanted to have something that stuck out and made it clear instead of just /
. Does that clarify this?
dacb20b
to
1ae0a5e
Compare
37f5414
to
77bb679
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just double check the hardcoded URL
return bodyString, nil | ||
} | ||
|
||
func PostTestDataToObserve(data any, path string, v *viper.Viper) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I'd just call it PostDataToObserve
😆
import ( | ||
"testing" | ||
|
||
"github.com/jarcoal/httpmock" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah httpmock is the best way to do this!
"github.com/spf13/cobra" | ||
) | ||
|
||
const TestDataPath = "/observe-agent/test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you are sending to https://observe-agent/test/ , I think maybe Alex meant that you can send the testdata to a hardcoded collect path of that specific test customer?
const TestDataPath = "/observe-agent/test" | ||
|
||
var defaultTestData = map[string]any{ | ||
"hello": "world", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes totally ok
b9897b1
to
b2ebf01
Compare
b2ebf01
to
92d4610
Compare
92d4610
to
7a5c1ff
Compare
Description
OB-32242 Create a new sub command to send test JSON data directly to Observe via HTTP post API.
Example usage:
Example result:
Checklist