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

pkg/trace/api: add /info discovery endpoint #7344

Merged
merged 17 commits into from
Feb 12, 2021
Merged

pkg/trace/api: add /info discovery endpoint #7344

merged 17 commits into from
Feb 12, 2021

Conversation

gbbr
Copy link
Contributor

@gbbr gbbr commented Feb 3, 2021

Example response from http://localhost:8126/info:

{
	"version": "0.99.0",
	"git_commit": "fab047e10",
	"build_date": "2020-12-04 15:57:06.74187 +0200 EET m=+0.029001792",
	"endpoints": [
		"/v0.3/traces",
		"/v0.3/services",
		"/v0.4/traces",
		"/v0.4/services",
		"/v0.5/traces",
		"/v0.5/stats",
		"/profiling/v1/input"
	],
	"feature_flags": [
		"feature_flag"
	],
	"config": {
		"default_env": "prod",
		"bucket_interval": 1000000000,
		"extra_aggregators": [
			"agg:val"
		],
		"extra_sample_rate": 2.4,
		"target_tps": 11,
		"max_eps": 12,
		"receiver_port": 8111,
		"receiver_socket": "/sock/path",
		"connection_limit": 12,
		"receiver_timeout": 100,
		"max_request_bytes": 123,
		"statsd_port": 123,
		"max_memory": 1000000,
		"max_cpu": 12345,
		"analyzed_rate_by_service_legacy": {
			"X": 1.2
		},
		"analyzed_spans_by_service": {
			"X": {
				"Y": 2.4
			}
		},
		"obfuscation": {
			"elastic_search": true,
			"mongo": true,
			"sql_exec_plan": true,
			"sql_exec_plan_normalize": true,
			"http": {
				"remove_query_string": true,
				"remove_path_digits": true
			},
			"remove_stack_traces": false,
			"redis": true,
			"memcached": false
		}
	}
}

@gbbr gbbr added this to the Triage milestone Feb 3, 2021
@gbbr gbbr changed the title initial commit pkg/trace/api: add discovery endpoint Feb 3, 2021
@gbbr gbbr marked this pull request as ready for review February 9, 2021 14:49
@gbbr gbbr requested a review from a team as a code owner February 9, 2021 14:49
pkg/trace/api/api.go Outdated Show resolved Hide resolved
@richardstartin
Copy link
Member

Hi @gbbr

What do values like those below mean? It looks to me like a feature flag hasn't been set. The client wouldn't expect these to be null but booleans. These would parse as false in some languages but I believe they are actually set by default in the trace agent.

"Obfuscation": null,
"ReplaceTags": null

This one looks like an actually nullable value, rather than the consequence of an unset feature flag, and I'd argue complete absence is a better policy in this case.

"ProxyURL": null

@gbbr
Copy link
Contributor Author

gbbr commented Feb 10, 2021

@richardstartin nothing that is in the Config is a feature flag. A "feature flag" is simply an experimental option that may be enabled or not (and will eventually be removed in subsequent versions) currently showing up in FeatureFlags section. I just want to clear that off so that there's no miscommunication moving forward.

Obfuscation and ReplaceTags are both objects, not booleans. I have made a new commit to leave this out from the response when they are null. They specify the configuration for the obfuscator, basically the contents of that section in the datadog.yaml file (see this link). As for the tag replacer, see this link. Most of what's in the Config key is from that file...

@gbbr
Copy link
Contributor Author

gbbr commented Feb 10, 2021

If it helps, here's a fully populated example object from the tests:

"Version": "0.99.0",
"GitCommit": "fab047e10",
"BuildDate": "2020-12-04 15:57:06.74187 +0200 EET m=+0.029001792",
"Endpoints": [
"/v0.3/traces",
"/v0.3/services",
"/v0.4/traces",
"/v0.4/services",
"/v0.5/traces",
"/v0.5/stats",
"/profiling/v1/input"
],
"FeatureFlags": [
"feature_flag"
],
"Config": {
"Enabled": true,
"Hostname": "test.host.name",
"DefaultEnv": "prod",
"ConfigPath": "/path/to/config",
"Endpoints": [
{
"Host": "https://target-intake.datadoghq.com",
"NoProxy": true
}
],
"BucketInterval": 1000000000,
"ExtraAggregators": [
"agg:val"
],
"ExtraSampleRate": 2.4,
"TargetTPS": 11,
"MaxEPS": 12,
"ReceiverHost": "localhost",
"ReceiverPort": 8111,
"ReceiverSocket": "/sock/path",
"ConnectionLimit": 12,
"ReceiverTimeout": 100,
"MaxRequestBytes": 123,
"StatsWriter": {
"ConnectionLimit": 20,
"QueueSize": 12,
"FlushPeriodSeconds": 14.4
},
"TraceWriter": {
"ConnectionLimit": 21,
"QueueSize": 13,
"FlushPeriodSeconds": 15.4
},
"ConnectionResetInterval": 0,
"StatsdHost": "stastd.localhost",
"StatsdPort": 123,
"LogLevel": "WARN",
"LogFilePath": "/path/to/logfile",
"LogThrottling": false,
"MaxMemory": 1000000,
"MaxCPU": 12345,
"WatchdogInterval": 60000000000,
"ProxyURL": {
"Scheme": "http",
"Opaque": "",
"User": null,
"Host": "localhost:8888",
"Path": "/proxy",
"RawPath": "",
"ForceQuery": false,
"RawQuery": "",
"Fragment": "",
"RawFragment": ""
},
"SkipSSLValidation": false,
"Ignore": {
"K": [
"1",
"2"
]
},
"ReplaceTags": [
{
"Name": "a",
"Pattern": "*",
"Re": null,
"Repl": "b"
}
],
"AnalyzedRateByServiceLegacy": {
"X": 1.2
},
"AnalyzedSpansByService": {
"X": {
"Y": 2.4
}
},
"DDAgentBin": "/path/to/core/agent",
"Obfuscation": {
"ES": {
"Enabled": true,
"KeepValues": [
"a",
"b",
"c"
],
"ObfuscateSQLValues": [
"x",
"y"
]
},
"Mongo": {
"Enabled": true,
"KeepValues": [
"a",
"b",
"c"
],
"ObfuscateSQLValues": [
"x",
"y"
]
},
"SQLExecPlan": {
"Enabled": true,
"KeepValues": [
"a",
"b",
"c"
],
"ObfuscateSQLValues": [
"x",
"y"
]
},
"SQLExecPlanNormalize": {
"Enabled": true,
"KeepValues": [
"a",
"b",
"c"
],
"ObfuscateSQLValues": [
"x",
"y"
]
},
"HTTP": {
"RemoveQueryString": true,
"RemovePathDigits": true
},
"RemoveStackTraces": false,
"Redis": {
"Enabled": true
},
"Memcached": {
"Enabled": false
}
}
}
}` {

@gbbr
Copy link
Contributor Author

gbbr commented Feb 10, 2021

Removed ProxyURL which is probably not interesting at all to a tracer... The rest we can leave for debugging...

@gbbr gbbr requested a review from dougqh February 10, 2021 12:38
@gbbr gbbr modified the milestones: Triage, 7.27.0 Feb 10, 2021
pkg/trace/api/api_test.go Outdated Show resolved Hide resolved
pkg/trace/api/api_test.go Outdated Show resolved Hide resolved
pkg/trace/api/api_test.go Outdated Show resolved Hide resolved
@gbbr
Copy link
Contributor Author

gbbr commented Feb 11, 2021

@dougqh @richardstartin I took all of your feedback, and made the Go code uglier in order to get prettier JSON. I also manually selected which config options should show up, and removed any which seemed like they might contain sensitive information or be irrelevant to the user tracer. Furthermore, I made the obfuscation configurations as booleans as requested.

Please check the updated PR description and let me know your thoughts.

@gbbr gbbr changed the title pkg/trace/api: add discovery endpoint pkg/trace/api: add /info discovery endpoint Feb 11, 2021
Copy link
Member

@richardstartin richardstartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

rec := httptest.NewRecorder()
req := httptest.NewRequest("GET", "/info", nil)
h.ServeHTTP(rec, req)
if rec.Body.String() != `{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I didn't know that there is field ordering on the JSON marshal. I would have expected maps to be flaky due to go random iterations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maps can't be flaky in ordering when they have only one element 🤷‍♂️ 😄 I didn't even notice.

@gbbr gbbr merged commit 79eb96f into master Feb 12, 2021
@gbbr gbbr deleted the gbbr/discovery branch February 12, 2021 11:04
gbbr added a commit to DataDog/dd-trace-go that referenced this pull request Apr 28, 2021
…gs, stats & drops (#859)

This change adds a multitude of new features, such as support for feature flags, agent discovery, client-side stats computations and enabling the dropping of P0 traces in the client.

### Feature flags

Support for feature flags by means of:
* `WithFeatureFlags` tracer start option.
* `DD_TRACE_FEATURES` environment variable which takes a list of comma or space separated flag tokens.

### Agent discovery

When the feature flag `discovery` is set, support for detecting features by means of the new agent (7.27.0) discovery endpoint added in DataDog/datadog-agent#7344 and DataDog/datadog-agent#7495 becomes enabled.

### Client-computed stats and dropping p0's

When `discovery` is enabled, if the agent supports client-computed stats and dropping p0's in the client, the tracer can now do this by means of the newly added concentrator and drop logic.

### TODO

* Obfuscation is not yet supported in the client but will be added in a subsequent PR by factoring out the obfuscator code from the agent into a separate package to be shared with this module.
nicoledanuwidjaja pushed a commit to DataDog/dd-trace-go that referenced this pull request May 5, 2021
…gs, stats & drops (#859)

This change adds a multitude of new features, such as support for feature flags, agent discovery, client-side stats computations and enabling the dropping of P0 traces in the client.

### Feature flags

Support for feature flags by means of:
* `WithFeatureFlags` tracer start option.
* `DD_TRACE_FEATURES` environment variable which takes a list of comma or space separated flag tokens.

### Agent discovery

When the feature flag `discovery` is set, support for detecting features by means of the new agent (7.27.0) discovery endpoint added in DataDog/datadog-agent#7344 and DataDog/datadog-agent#7495 becomes enabled.

### Client-computed stats and dropping p0's

When `discovery` is enabled, if the agent supports client-computed stats and dropping p0's in the client, the tracer can now do this by means of the newly added concentrator and drop logic.

### TODO

* Obfuscation is not yet supported in the client but will be added in a subsequent PR by factoring out the obfuscator code from the agent into a separate package to be shared with this module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team/agent-apm trace-agent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants