Skip to content
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

Obtaining sampling rules may silently fail #5717

Closed
jaedle opened this issue Jun 3, 2024 · 10 comments
Closed

Obtaining sampling rules may silently fail #5717

jaedle opened this issue Jun 3, 2024 · 10 comments
Labels
bug Something isn't working sampler: aws:xray

Comments

@jaedle
Copy link
Contributor

jaedle commented Jun 3, 2024

Description

The X-Ray remote sampler may silently fail obtaining the sampling rules from the awsproxy.

We are running the OpenTelemetry Collector behind a reverse proxy as we have about a dozen services ingesting traces which are forwarded to AWS X-Ray. As this adds forward headers (i.e. x-forwarded-*), the request signing of the awsproxy was not working correctly.

Even though the response of AWS results in a client error, there are no signs of an error. The JSON response body is unmarshaled and treated as empty ruleset.

The missing check on status code of the response should be the problem in this case.

The only response code for a successful request should be 200/OK according the documentation.

Environment

Should not be relevant for the error.

Steps To Reproduce

The simplest way to reproduce may be a test case for client_test.go:

func TestRespondsWithErrorStatusCode(t *testing.T) {
	testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, _ *http.Request) {
		res.WriteHeader(http.StatusForbidden)
		_, err := res.Write([]byte(`{}`))
		require.NoError(t, err)
	}))
	t.Cleanup(testServer.Close)

	u, err := url.Parse(testServer.URL)
	require.NoError(t, err)

	client, err := newClient(*u)
	require.NoError(t, err)

	samplingRules, err := client.getSamplingRules(context.Background())
	require.Error(t, err)
	require.Nil(t, samplingRules)
}

Current behavior

GIVEN sampling rules should be obtained from the xray proxy
WHEN the response code incidcates an error 4xx/5xx
THEN an empty manifest is created
AND no error is indicated

Expected behavior

GIVEN sampling rules should be obtained from the xray proxy
WHEN the response code incidcates an error 4xx/5xx
THEN an error should occur on loading the rulset
AND no manifest should be present 

I would love to provide a PR to fix that issue.

@jaedle jaedle added bug Something isn't working sampler: aws:xray labels Jun 3, 2024
@jaedle
Copy link
Contributor Author

jaedle commented Jun 3, 2024

I have already seen #5554 and hope that @wangzlei could jump in reviewing the PR I would love to raise. 🙏

@jaedle jaedle changed the title Obtaining sampling rules may result in a undected error. Obtaining sampling rules may result in a undected error Jun 3, 2024
@jaedle jaedle changed the title Obtaining sampling rules may result in a undected error Obtaining sampling rules may silently fail Jun 3, 2024
@ayushrakesh
Copy link

@jaedle Is this issue still need to fix or already solved?

@jaedle
Copy link
Contributor Author

jaedle commented Jun 23, 2024

@jaedle Is this issue still need to fix or already solved?

Still open, see #5718.

@ayushrakesh
Copy link

@jaedle Thanks , I am starting working on it.

@jaedle
Copy link
Contributor Author

jaedle commented Jun 23, 2024

@ayushrakesh I am sorry if you got this wrong, but did you have a look at the existing PR #5718?

@ayushrakesh
Copy link

ayushrakesh commented Jun 23, 2024

@jaedle Oh, there is already a PR. Sorry.

@jaedle
Copy link
Contributor Author

jaedle commented Jun 23, 2024

Ok 👌

May I ask why you created a new PR?

Having a look at your changes those look pretty similar to the existing PR which was already reviewed.

@ayushrakesh
Copy link

Yeah, sorry for it, I thought PR is not made yet.

@jaedle
Copy link
Contributor Author

jaedle commented Jun 23, 2024

I am very sorry if I was unclear 🙁

@ayushrakesh
Copy link

No no, that's my fault.🥲

@jaedle jaedle closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sampler: aws:xray
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants