Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opentracing-contrib/java-web-servlet-filter
OpenTracing Java Web Servlet Filter Instrumentation
https://github.com/opentracing-contrib/java-web-servlet-filter
filter instrumentation opentracing servlet tracing
Last synced: 6 days ago
JSON representation
OpenTracing Java Web Servlet Filter Instrumentation
- Host: GitHub
- URL: https://github.com/opentracing-contrib/java-web-servlet-filter
- Owner: opentracing-contrib
- License: apache-2.0
- Created: 2017-01-12T18:50:00.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-07-07T20:59:40.000Z (over 2 years ago)
- Last Synced: 2025-01-08T01:21:05.204Z (14 days ago)
- Topics: filter, instrumentation, opentracing, servlet, tracing
- Language: Java
- Homepage:
- Size: 173 KB
- Stars: 25
- Watchers: 5
- Forks: 31
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status][ci-img]][ci] [![Released Version][maven-img]][maven]
# OpenTracing Java Web Servlet Filter Instrumentation
This library provides instrumentation for Java Web Servlet applications.
## Initialization
Tracing filter can be programmatically initialized:
```java
TracingFilter filter = new TracingFilter(tracer);
servletContext.addFilter("tracingFilter", filter);
```or added to `web.xml`, however it requires to register a tracer instance: `GlobalTracer.register(tracer)`.
## Tracer override
If a tracer has been associated with the `ServletContext` as an attribute with key `io.opentracing.Tracer`,
then it will override any tracer explicitly passed to the filter or registered with the `GlobalTracer`.This approach can be used where OpenTracing and Tracer implementation specific dependencies are configured within a
servlet container (rather than bundled with the webapp), and we don't wish to share a single `GlobalTracer` instance
across all webapps (e.g. as this may mean all webapps report their spans associated with the same service name).In these situations, using a `ServletContextListener` to create a `Tracer` will enable it to be specific to the webapp and
managed with its lifecycle.## Accessing Server Span
Current server span context is accessible in HttpServletRequest attributes.
```java
SpanContext spanContext = (SpanContext)httpservletRequest.getAttribute(TracingFilter.SERVER_SPAN_CONTEXT);
```## Development
```shell
./mvnw clean install
```## Release
Follow instructions in [RELEASE](RELEASE.md)[ci-img]: https://travis-ci.org/opentracing-contrib/java-web-servlet-filter.svg?branch=master
[ci]: https://travis-ci.org/opentracing-contrib/java-web-servlet-filter
[maven-img]: https://img.shields.io/maven-central/v/io.opentracing.contrib/opentracing-web-servlet-filter.svg?maxAge=2592000
[maven]: http://search.maven.org/#search%7Cga%7C1%7Copentracing-web-servlet-filter