Skip to content

Commit

Permalink
[loadgen] - add baggage (#331)
Browse files Browse the repository at this point in the history
* add baggage

* add baggage

* add load generator baggage
  • Loading branch information
puckpuck authored Aug 24, 2022
1 parent fc997b6 commit 2e7a702
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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()

0 comments on commit 2e7a702

Please sign in to comment.