Skip to content

Commit

Permalink
feat: implement HoneycombOptions (#2)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

Implements `HoneycombOptions`, including `HoneycombOptions.Builder`, as
per the design doc.

## Short description of the changes

* If a plist file is passed into the constructor, `Builder` is
pre-populated with its values.
* There are setters for all values.
* `HoneycombOptions` only contains specific values like
`tracesEndpoint`, whereas the `Builder` has fallback settings like
`setEndpoint`. The specific values are resolved when `build()` is
called.
* Automatic headers and resources are injected upon calling `build()`.
* The only required field is `APIKey`.
* Throws HoneycombOptionsError on any fatal configuration error. These
should only be unexpected developer bugs, not expected runtime errors.

## How to verify that this has the expected result

There are comprehensive unit tests that I believe test all plist values,
setters, and fallbacks, as well as any error conditions.

In review please look for the following:
* Are there any missing unit test cases?
* Is the fallback logic correct?
* Are the resources and headers auto-populated correctly?
* Should the error cases actually be error cases?
  • Loading branch information
beekhc authored Aug 7, 2024
1 parent 34fb34d commit d1b1d18
Show file tree
Hide file tree
Showing 9 changed files with 1,524 additions and 20 deletions.
150 changes: 150 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"originHash" : "1d753dc79b1d84a6ff809fe2b0ee15d4174ecaae798abba08103061974e1908b",
"pins" : [
{
"identity" : "grpc-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift.git",
"state" : {
"revision" : "6a90b7e77e29f9bda6c2b3a4165a40d6c02cfda1",
"version" : "1.23.0"
}
},
{
"identity" : "opentelemetry-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/open-telemetry/opentelemetry-swift.git",
"state" : {
"revision" : "0dd37c4a14a6aeeb131eea40a13cb3832c7c6a97",
"version" : "1.10.1"
}
},
{
"identity" : "opentracing-objc",
"kind" : "remoteSourceControl",
"location" : "https://github.com/undefinedlabs/opentracing-objc",
"state" : {
"revision" : "18c1a35ca966236cee0c5a714a51a73ff33384c1",
"version" : "0.5.2"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "3d2dc41a01f9e49d84f0a3925fb858bed64f702d",
"version" : "1.1.2"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd",
"version" : "1.3.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
}
},
{
"identity" : "swift-metrics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "e0165b53d49b413dd987526b641e05e246782685",
"version" : "2.5.0"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "4c4453b489cf76e6b3b0f300aba663eb78182fad",
"version" : "2.70.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "05c36b57453d23ea63785d58a7dbc7b70ba1745e",
"version" : "1.23.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "b5f7062b60e4add1e8c343ba4eb8da2e324b3a94",
"version" : "1.34.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "a9fa5efd86e7ce2e5c1b6de113262e58035ca251",
"version" : "2.27.1"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "38ac8221dd20674682148d6451367f89c2652980",
"version" : "1.21.0"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "e17d61f26df0f0e06f58f6977ba05a097a720106",
"version" : "1.27.1"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5",
"version" : "1.3.2"
}
},
{
"identity" : "thrift-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/undefinedlabs/Thrift-Swift",
"state" : {
"revision" : "18ff09e6b30e589ed38f90a1af23e193b8ecef8e",
"version" : "1.1.2"
}
}
],
"version" : 3
}
25 changes: 19 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,32 @@ import PackageDescription

let package = Package(
name: "honeycomb-opentelemetry-swift",
platforms: [
.macOS(.v10_15),
.iOS(.v12),
.tvOS(.v12)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "honeycomb-opentelemetry-swift",
targets: ["honeycomb-opentelemetry-swift"]),
.library(name: "Honeycomb", type: .static, targets: ["Honeycomb"]),
],
dependencies: [
// This revision is needed for now to avoid unsafe flags.
.package(url: "https://github.com/open-telemetry/opentelemetry-swift.git", from:"1.10.1")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "honeycomb-opentelemetry-swift"),
name: "Honeycomb",
dependencies: [
.product(name: "OpenTelemetryApi", package: "opentelemetry-swift"),
.product(name: "OpenTelemetrySdk", package: "opentelemetry-swift"),
.product(name: "OpenTelemetryProtocolExporter", package: "opentelemetry-swift"),
.product(name: "OpenTelemetryProtocolExporterHTTP", package: "opentelemetry-swift"),
]),
.testTarget(
name: "honeycomb-opentelemetry-swiftTests",
dependencies: ["honeycomb-opentelemetry-swift"]),
name: "HoneycombTests",
dependencies: ["Honeycomb"]),
]
)
Loading

0 comments on commit d1b1d18

Please sign in to comment.