Skip to content

Commit 9cd9431

Browse files
author
Ignacio Bonafonte
authored
Merge pull request #176 from nachoBonafonte/add-missing-readme
2 parents 0737ab2 + 5807360 commit 9cd9431

File tree

7 files changed

+56
-11
lines changed

7 files changed

+56
-11
lines changed

Examples/Network Sample/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Network sample
2+
3+
This example shows the `URLSessionInstrumentation` in action.
4+
It only shows the minimum configuration: Just by initializing the class, all network request that happen after it will be captured by Opentelemetry as Spans. Check [`URLSessionInstrumentation` README](Sources/Instrumentation/URLSession/README.md) for more information.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### OpenTracingShim
2+
3+
An OpenTracing implementation that delegates to the OpenTelemetry SDK. Use OpenTracingShim to create tracers using this implementation.
4+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### SwiftMetricsShim
2+
3+
Apple have created their own metrics API which has been adopted by a number of other packages including, but not limited to, Vapor - a prominent Server Side Swift platform.
4+
5+
This shim essentially redirects the data to the OpenTelemetry API functions.
6+
7+
```
8+
let meter: Meter = // ... Your existing code to create a meter
9+
let metrics = OpenTelemetrySwiftMetrics(meter: meter)
10+
MetricsSystem.bootstrap(metrics)
11+
```

Sources/Instrumentation/SDKResourceExtension/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# iOS Resource extension
1+
# SDK Resource extension
22

3-
This package captures a number of key data points of an iOS application and generates a Resource object that can be passed to a `TracerProvider`
3+
This package captures a number of key data points of an application and generates a Resource object that can be passed to a `TracerProvider`
44

55

66
## Usage
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# URL Session instrumentation
2+
3+
This package captures the network calls produced by URLSession.
4+
5+
6+
## Usage
7+
8+
Initialize the class with `URLSessionInstrumentation(configuration: URLSessionInstrumentationConfiguration())` to automatically capture all network calls.
9+
10+
This behaviour can be modified or augmented by using the optional callbacks defined in `URLSessionInstrumentationConfiguration` :
11+
12+
`shouldInstrument: ((URLRequest) -> (Bool)?)?` : Filter which requests you want to instrument, all by default
13+
14+
`shouldRecordPayload: ((URLSession) -> (Bool)?)?`: Implement if you want the session to record payload data, false by default.
15+
16+
`shouldInjectTracingHeaders: ((inout URLRequest) -> (Bool)?)?`: Allows filtering which requests you want to inject headers to follow the trace, true by default. You can also modify the request or add other headers in this method.
17+
18+
`nameSpan: ((URLRequest) -> (String)?)?` - Modifies the name for the given request instead of stantard Opentelemetry name
19+
20+
`createdRequest: ((URLRequest, Span) -> Void)?` - Called after request is created, it allows to add extra information to the Span
21+
22+
`receivedResponse: ((URLResponse, DataOrFile?, Span) -> Void)?`- Called after response is received, it allows to add extra information to the Span
23+
24+
`receivedError: ((Error, DataOrFile?, HTTPStatus, Span) -> Void)?` - Called after an errror is received, it allows to add extra information to the Span
25+
26+

Sources/Instrumentation/URLSession/URLSessionInstrumentationConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public struct URLSessionInstrumentationConfiguration {
5757
/// default name: `HTTP {method}` e.g. `HTTP PUT`
5858
public var nameSpan: ((URLRequest) -> (String)?)?
5959

60-
/// Called before the span is created, it allows to add extra information to the Span through the builder
60+
/// Called before the span is created, it allows to add extra information to the Span
6161
public var createdRequest: ((URLRequest, Span) -> Void)?
6262

6363
/// Called before the span is ended, it allows to add extra information to the Span

Sources/OpenTelemetrySdk/Trace/MultiSpanProcessor.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import OpenTelemetryApi
1818

1919
/// Implementation of the SpanProcessor that simply forwards all received events to a list of
2020
/// SpanProcessors.
21-
struct MultiSpanProcessor: SpanProcessor {
21+
public struct MultiSpanProcessor: SpanProcessor {
2222
var spanProcessorsStart = [SpanProcessor]()
2323
var spanProcessorsEnd = [SpanProcessor]()
2424
var spanProcessorsAll = [SpanProcessor]()
2525

26-
init(spanProcessors: [SpanProcessor]) {
26+
public init(spanProcessors: [SpanProcessor]) {
2727
spanProcessorsAll = spanProcessors
2828
spanProcessorsAll.forEach {
2929
if $0.isStartRequired {
@@ -35,33 +35,33 @@ import OpenTelemetryApi
3535
}
3636
}
3737

38-
var isStartRequired: Bool {
38+
public var isStartRequired: Bool {
3939
return spanProcessorsStart.count > 0
4040
}
4141

42-
var isEndRequired: Bool {
42+
public var isEndRequired: Bool {
4343
return spanProcessorsEnd.count > 0
4444
}
4545

46-
func onStart(parentContext: SpanContext?, span: ReadableSpan) {
46+
public func onStart(parentContext: SpanContext?, span: ReadableSpan) {
4747
spanProcessorsStart.forEach {
4848
$0.onStart(parentContext: parentContext, span: span)
4949
}
5050
}
5151

52-
func onEnd(span: ReadableSpan) {
52+
public func onEnd(span: ReadableSpan) {
5353
for var processor in spanProcessorsEnd {
5454
processor.onEnd(span: span)
5555
}
5656
}
5757

58-
func shutdown() {
58+
public func shutdown() {
5959
for var processor in spanProcessorsAll {
6060
processor.shutdown()
6161
}
6262
}
6363

64-
func forceFlush() {
64+
public func forceFlush() {
6565
spanProcessorsAll.forEach {
6666
$0.forceFlush()
6767
}

0 commit comments

Comments
 (0)