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

[loadgen] - add baggage #331

Merged
merged 4 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ significant modifications will be credited to OpenTelemetry Authors.
([#317](https://github.com/open-telemetry/opentelemetry-demo/pull/317))
* Updated Product Catalog to Match Astronomy Webstore
([#285](https://github.com/open-telemetry/opentelemetry-demo/pull/285))
* Add `synthetic_request=true` baggage to load generator requests
([#331](https://github.com/open-telemetry/opentelemetry-demo/pull/331))
10 changes: 6 additions & 4 deletions src/loadgenerator/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import uuid
from locust import HttpUser, task, between

from opentelemetry import trace
from opentelemetry import context, baggage, trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (BatchSpanProcessor)
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
Expand Down Expand Up @@ -211,18 +211,18 @@ def index(self):

@task(10)
def browse_product(self):
self.client.get("/product/" + random.choice(products))
self.client.get("/api/products/" + random.choice(products))

@task(3)
def view_cart(self):
self.client.get("/cart")
self.client.get("/api/cart")

@task(2)
def add_to_cart(self, user=""):
if user == "":
user = str(uuid.uuid1())
product = random.choice(products)
self.client.get("/product/" + product)
self.client.get("/api/products/" + product)
cart_item = {
"item": {
"productId": product,
Expand Down Expand Up @@ -252,4 +252,6 @@ def checkout_multi(self):
self.client.post("/api/checkout", json=checkout_person)

def on_start(self):
ctx = baggage.set_baggage("synthetic_request", "true")
context.attach(ctx)
self.index()