Skip to content

[load-generator] Update locustfile for logging with TraceContext #2265

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ps48
Copy link
Contributor

@ps48 ps48 commented Jun 16, 2025

Changes

  • Added LoggingInstrumentor: This is an addition that automatically injects trace context (trace_id, span_id) into all log records.
  • Reorganized initialization order: Moved the tracer provider before the logger provider to ensure trace context is available.
  • Added consistent Resource: Used the same resource across all telemetry signals for better correlation.
  • Wrapped tasks in spans: Each task method now creates a span, which provides trace context for any logs within that span.
  • Added explicit logging: Added log statements within spans so you can see the trace context in action.
  • Added span attributes: Added relevant attributes to spans for better observability.

Related issue: #2250

Merge Requirements

For new features contributions, please make sure you have completed the following
essential items:

  • CHANGELOG.md updated to document new feature additions
  • Appropriate documentation updates in the docs
  • Appropriate Helm chart updates in the helm-charts

Maintainers will not merge until the above have been completed. If you're unsure
which docs need to be changed ping the
@open-telemetry/demo-approvers.

Signed-off-by: Shenoy Pratik <pshenoy36@gmail.com>
@ps48 ps48 changed the title Update locustfile for logging with traceContext Update locustfile for logging with TraceContext Jun 16, 2025
Signed-off-by: Shenoy Pratik <pshenoy36@gmail.com>
@ps48 ps48 marked this pull request as ready for review June 16, 2025 16:10
@ps48 ps48 requested a review from a team as a code owner June 16, 2025 16:10
@ps48 ps48 changed the title Update locustfile for logging with TraceContext [load-generator] Update locustfile for logging with TraceContext Jun 16, 2025
Copy link
Member

@julianocosta89 julianocosta89 left a comment

Choose a reason for hiding this comment

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

Hey @ps48 thanks for taking care of that.

I've left some comments, basically to remove the resource and rely on the service name coming from the env var, and asking to keep just one log entry per call.

Just to not explode the amount of data produced by the load-gen.

Comment on lines 44 to 46
resource = Resource.create({
"service.name": "load-generator",
})
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense removed the resource attribute injection.

Comment on lines +190 to +195
logging.info(f"User {user} performing single item checkout")
self.add_to_cart(user=user)
checkout_person = random.choice(people)
checkout_person["userId"] = user
self.client.post("/api/checkout", json=checkout_person)
logging.info(f"Checkout completed for user {user}")
Copy link
Member

Choose a reason for hiding this comment

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

All the new spans already increased a lot the amount of data leaving the load-gen service, let's keep just one log entry per call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, just kept the final log statement for each entry. db6f18a

Signed-off-by: Shenoy Pratik <pshenoy36@gmail.com>
@ps48
Copy link
Contributor Author

ps48 commented Jun 18, 2025

Hi @julianocosta89, this commit db6f18a should address all the mentioned changes.

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.

2 participants