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

Sampling override applicationinsights-java-agent telemetryType requests not work #3949

Open
serignemodou opened this issue Nov 8, 2024 · 12 comments

Comments

@serignemodou
Copy link

serignemodou commented Nov 8, 2024

Expected behavior
I want to

  • capture 100% for only some requests url that contains path /parcours
  • Not capture all the rest
    I'm following this document

Actual behavior
The override is ignored.

To Reproduce
I'm using

  • Spring Boot v3.2.3
  • Applicationinsights-agent 3.5.1

Below is my applicationinsights.json configuration:

{
	"connectionString": "key-applicationinsights"
	"role": {
		"name": "demo name"
	},
	"instrumentation": {
		"logging": {
			"level": "TRACE"
		}
	},
	"selfDiagnostics": {
		"destination":"file+console",
		"level": "DEBUG",
		"file": {
			"path": "applicationinsights.log",
			"maxSizeMb": 5,
			"maxHistory": 1
		}
	},  
	"sampling": {
		"percentage": 0,
		"overrides":  [ 
			{
				"telemetryType": "request",
				"attributes": [
				  {
					"key": "url.path",
					"value": ".*/parcours/.*",
					"matchType": "regexp"
				  }
				],
				"percentage": 100
			}
		]
	}
}

**Logs result on app insights requests Image
As you can see, all the logs are collected, that's means the sampling override is ignored.

@serignemodou
Copy link
Author

By looking, the span attributes in the logs, i found that my key, value are not directely on the attributs list
attributes=AttributesMap{data={url.scheme=https, network.peer.port=39621, http.request.method=GET, http.route=/app/v1/health-check, url.path=/app/v1/parcours/utilisateurs}

How can I access this value key ?

@trask
Copy link
Member

trask commented Nov 8, 2024

are you getting any warnings from the Java agent on startup? it looks like you're missing a comma in your json, so I'd expect the Java agent to log this as a warning on startup

@serignemodou
Copy link
Author

serignemodou commented Nov 10, 2024

On the first line no, i made a mistake on the copy.
I have no warning on the agent

@serignemodou
Copy link
Author

it seems that the span does not record the attributes, on the agent logs I see the attribute field empty attributes={}

@trask
Copy link
Member

trask commented Nov 10, 2024

what about the log you pasted above? that one looked like it picked up url.path:

attributes=AttributesMap{data={url.scheme=https, network.peer.port=39621, http.request.method=GET, http.route=/app/v1/health-check, url.path=/app/v1/parcours/utilisateurs}

@serignemodou
Copy link
Author

serignemodou commented Nov 12, 2024

I think the key value url.path is not setter in the right place.
It should be in the attributes list, which currently only contains the keys/values attributes={service.name=‘my-service-name’, telemetry.sdk.language=‘java’, telemetry.sdk.name=‘opentelemetry’, telemetry.sdk.version=‘1.35.0’}} , and not in the list of attributes attributes=AttributesMap{data={url.scheme=https, network.peer.port=39621, http.request.method=GET, http.route=/app/v1/health-check, url.path=/app/v1/parcours/utilisateurs}

it seems normal to me that the filter on the url.path attribute doesn't work, because it looks for values on attributes={} and not on attributes=AttributesMaps{data={}}

How i can set this key/value in the attributes list ?

@trask
Copy link
Member

trask commented Nov 13, 2024

attributes={service.name=‘my-service-name’, telemetry.sdk.language=‘java’, telemetry.sdk.name=‘opentelemetry’, telemetry.sdk.version=‘1.35.0’}}

these are opentelemetry resource attributes and are not supported by the sampling overrides

http.route isn't supported by sampling overrides b/c it is typically set after span start

url.path should work

would you be able to create a small repro that we can look at to see what the issue might be?

@serignemodou
Copy link
Author

serignemodou commented Nov 13, 2024

Ok,
Unfortunately the url.path not work for me.
I have a repo demo, i invited to join it.

@trask
Copy link
Member

trask commented Nov 13, 2024

hi @serignemodou, thanks for the demo app. I ran it locally and hit http://localhost:8080/app/v1/health-check/test and didn't see any request telemetry captured.

How does it work for you locally (not in App Services)? thanks

@serignemodou
Copy link
Author

serignemodou commented Nov 13, 2024

Hi @trask
Exact, it work well locally.
Do you have an idea on why it doesn't work on App Service ?

@trask
Copy link
Member

trask commented Nov 13, 2024

Are you using the Application Insights / App Services Integration? that will automatically add the -javaagent which will take precedence over the runtime attach, and so won't pick up your json configuration file

@serignemodou
Copy link
Author

serignemodou commented Nov 14, 2024

Hi,
I haved disabled -javaagent by deleting the app service env variable ApplicationInsightsAgent_EXTENSION_VERSION, now i only use runtime attach.
But, the file config applicationinsights.json is not loaded, as a result no logs are collected
i followed this documentation to configure the runtime attach app insigths spring boot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants