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

feat: support tracing rule sampler #3405

Merged
merged 2 commits into from Mar 5, 2024

Conversation

Taylor-lagrange
Copy link
Contributor

@Taylor-lagrange Taylor-lagrange commented Feb 28, 2024

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Implement a tracing sampler, the sampling rate of tracing can be determined based on different protocol and request_types of the protocol.

Current support protocol and request_types:

protocol request_type
grpc inserts/ query.sql / query.logical_plan / query.prom_range / query.empty / ddl.create_database / ddl.create_table / ddl.alter / ddl.drop_table / ddl.truncate_table / ddl.empty / deletes / row_inserts / row_deletes
mysql
postgres
otlp metrics / traces
opentsdb
influxdb write_v1 / write_v2
prometheus remote_read/remote_write/format_query/instant_query/range_query/labels_query/series_query/label_values_query
http sql / promql

User can config the tracing sampler rule by config like

[logging]
enable_otlp_tracing = true
otlp_endpoint = "localhost:4317"
# The percentage of tracing will be sampled and exported. Valid range `[0, 1]`, 1 means all traces are sampled, 0 means all traces are not sampled, the default value is 1. ratio > 1 are treated as 1. Fractions < 0 are treated as 0
[logging.tracing_sample_ratio]
default_ratio = 0.0
[[logging.tracing_sample_ratio.rules]]
protocol = "mysql"
ratio = 1.0
[[logging.tracing_sample_ratio.rules]]
protocol = "http"
request_types = ["sql"]
ratio = 0.3

The matching principle is to match rules one by one, and use the first match rule as the sampling rate. If no rules hit, the default ratio is used as the sampling rate.

At the entrance of each protocol&request_type, the corresponding fields are marked. The sampler matches these fields by rules, and finally determines the sampling rate of a certain protocol&request_type.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

Refer to a related PR or issue link (optional)

@Taylor-lagrange Taylor-lagrange added the docs-required This change requires docs update. label Feb 28, 2024
@github-actions github-actions bot added docs-required This change requires docs update. and removed docs-required This change requires docs update. labels Feb 28, 2024
Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 55.34591% with 71 lines in your changes are missing coverage. Please review.

Project coverage is 84.50%. Comparing base (8087822) to head (209903d).
Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3405      +/-   ##
==========================================
- Coverage   85.74%   84.50%   -1.25%     
==========================================
  Files         893      900       +7     
  Lines      147207   148511    +1304     
==========================================
- Hits       126222   125497     -725     
- Misses      20985    23014    +2029     

@waynexia waynexia added the docs-required This change requires docs update. label Feb 28, 2024
@github-actions github-actions bot removed the docs-required This change requires docs update. label Feb 28, 2024
src/common/telemetry/src/tracing_sampler.rs Show resolved Hide resolved
src/common/telemetry/src/tracing_sampler.rs Outdated Show resolved Hide resolved
src/common/telemetry/src/tracing_sampler.rs Outdated Show resolved Hide resolved
src/common/telemetry/src/tracing_sampler.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@zhongzc zhongzc left a comment

Choose a reason for hiding this comment

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

LGTM

@waynexia waynexia mentioned this pull request Mar 5, 2024
8 tasks
@waynexia waynexia merged commit 53f2a58 into GreptimeTeam:main Mar 5, 2024
21 of 23 checks passed
@Taylor-lagrange Taylor-lagrange deleted the feat-trace-sampler branch March 11, 2024 08:16
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

Successfully merging this pull request may close these issues.

None yet

4 participants