Lädt...


🔧 Tracetest Tip: Testing Span Order with Assertions


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

💡 Are you not sure how OpenTelemetry instrumentation or Trace-based testing works? Click here to see more details.

When you are instrumenting services with OpenTelemetry, you want to see traces propagated from service A to service B, and check if their communication is working as expected. For instance, in the example below, a user sends data to Service A and Service A calls Service B to augment it.

You can validate the communication flow with Tracetest using a selector in the following format.

  specs:
  - selector: span[service.name="service-a"] span[service.name="service-b"]
    assertions:
    - attr:tracetest.selected_spans.count >= 1
  • Declaring the selector in this order means that it will only select spans from service-b that come after spans from service-a.
  • The assertion attr:tracetest.selected_spans.count >= 1 validates that at least one span exists with that criteria. For further details, visit the selector documentation.

Going back to the example above, you can write a test with a specific assertion to validate it.

type: Test
spec:
  id: FMqdxukHg
  name: Test if service B is called after service A
  trigger:
    type: http
    httpRequest:
      method: POST
      url: http://service-a:8800/sendData
      body: "{\n  \"some\": \"test\" \n}"
      headers:
      - key: Content-Type
        value: application/json
  specs:
  - selector: span[tracetest.span.type="http" service.name="service-a" name="POST /sendData"] 
              span[tracetest.span.type="http" service.name="service-b" name="POST /augmentData"]
    name: Service B was called after Service A
    assertions:
    - attr:tracetest.selected_spans.count >= 1

When running this test with the CLI, you should have the following result.

tracetest run test -f ./tracetest/test.yaml

# It should output something like this:

# ✔ RunGroup: #uv8yYXkNg (https://app.tracetest.io/organizations/ttorg_1cbdabae7b8fd1c6/environments/ttenv_6e983cd1e9edbecf/run/uv8yYXkNg)
#  Summary: 1 passed, 0 failed, 0 pending
#   ✔ Test if service B is called after service A (https://app.tracetest.io/organizations/ttorg_1cbdabae7b8fd1c6/environments/ttenv_6e983cd1e9edbecf/test/FMqdxukHg/run/9/test) - trace id: 008075c573faf4583f42e67c9bdb4f83
#         ✔ Service B was called after Service A

By doing this type of assertion you can validate if the dependencies are organized as intended, and even use it to validate if a trace is being propagated between services.

Here’s what it looks like in the Tracetest UI.

image.png

The example sources used in this article and setup instructions are available in the Tracetest GitHub repository.

Would you like to learn more about Tracetest and what it brings to the table? Visit the Tracetest docs and try it out by signing up today!

Also, please feel free to join our Slack Community, give Tracetest a star on GitHub, or schedule a time to chat 1:1.

...

🔧 Tracetest Tip: Testing Span Order with Assertions


📈 98.13 Punkte
🔧 Programmierung

🔧 Testing with the xUnit Framework - More Assertions (4 of 12) | Automated Software Testing


📈 36.28 Punkte
🔧 Programmierung

🔧 Testing with the xUnit Framework - Theories and Assertions (3 of 12) | Automated Software Testing


📈 36.28 Punkte
🔧 Programmierung

🔧 Trace-based Testing With OpenTelemetry: Using Tracetest with OpenTelemetry


📈 32.59 Punkte
🔧 Programmierung

🔧 Tracetest Monitors: Trace-based testing meets Synthetic Monitoring 🔥


📈 32.59 Punkte
🔧 Programmierung

🔧 Sumo Logic and Tracetest: AI-Driven Observability Meets Testing


📈 32.59 Punkte
🔧 Programmierung

🔧 Event-driven Kubernetes testing with Testkube and Tracetest


📈 32.59 Punkte
🔧 Programmierung

🔧 Mastering Assertions in Python Selenium: A Comprehensive Guide for Testing


📈 30.21 Punkte
🔧 Programmierung

📰 Aduket - Straight-forward HTTP Client Testing, Assertions Included


📈 30.21 Punkte
📰 IT Security Nachrichten

🔧 Tracetest Monitors: Synthetic Monitoring with OpenTelemetry and Playwright


📈 26.52 Punkte
🔧 Programmierung

🔧 Tracetest + Artillery Launch Week Recap 💥


📈 26.52 Punkte
🔧 Programmierung

🔧 Observability-driven development with Go and Tracetest


📈 26.52 Punkte
🔧 Programmierung

🔧 Tracetest v0.9: Making Configuration Easy


📈 26.52 Punkte
🔧 Programmierung

🔧 Announcing Tracetest Enterprise On-Prem Solution


📈 26.52 Punkte
🔧 Programmierung

🔧 Dev Tip: How to view Dev Tip: How to view localhost web apps on your phone


📈 24.53 Punkte
🔧 Programmierung

🔧 Optimizing Your REST Assured Tests: Setting Default Host and Port, GET Requests, and Assertions


📈 24.13 Punkte
🔧 Programmierung

🔧 How To Simplify Assertions in Unit and Integration Tests with Verify in .NET


📈 24.13 Punkte
🔧 Programmierung

🔧 Top 5 Reasons to Use Shouldly for Assertions in .NET


📈 24.13 Punkte
🔧 Programmierung

🔧 Three optional styles for UI assertions in Cypress


📈 24.13 Punkte
🔧 Programmierung

🔧 Using Zero-Width Assertions in Regular Expressions


📈 24.13 Punkte
🔧 Programmierung

🔧 Generate assertions using AI


📈 24.13 Punkte
🔧 Programmierung

🔧 Type Guards & Type Assertions


📈 24.13 Punkte
🔧 Programmierung

📰 Meet Spade: An AI Method for Automatically Synthesizing Assertions that Identify Bad LLM Outputs


📈 24.13 Punkte
🔧 AI Nachrichten

🔧 Playwright Tutorial for Beginners 9 - Assertions


📈 24.13 Punkte
🔧 Programmierung

🔧 Best practices with const assertions in TypeScript


📈 24.13 Punkte
🔧 Programmierung

🔧 Type Assertions, Trucks, and Aliens


📈 24.13 Punkte
🔧 Programmierung

🔧 Stop requiring only one assertion per unit test: Multiple assertions are fine


📈 24.13 Punkte
🔧 Programmierung

🐧 Microsoft joins LOT Network, helping protect developers against patent assertions


📈 24.13 Punkte
🐧 Linux Tipps

🔧 Assert with Grace: Custom Soft Assertions using AssertJ for Cleaner Code


📈 24.13 Punkte
🔧 Programmierung

🎥 TIP: How To Change The Order Of Accounts In Thunderbird


📈 21.07 Punkte
🎥 Video | Youtube

matomo