Skip to content

Commit c3a58b6

Browse files
committed
Fix ameba/linting and bump version for release.
The Ameba version was too old, so it was bumped. An .ameba.yml file was introduced to better control linting rules, and the issues that Ameba identified were fixed. The shard.yml version and VERSION were bumped to 0.5.2 to prepare for a release.
1 parent ea8dae3 commit c3a58b6

File tree

7 files changed

+43
-27
lines changed

7 files changed

+43
-27
lines changed

.ameba.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This configuration file was generated by `ameba --gen-config`
2+
# on 2023-05-10 14:20:09 UTC using Ameba version 1.4.3.
3+
# The point is for the user to remove these configuration records
4+
# one by one as the reported problems are removed from the code base.
5+
6+
# Problems found: 643
7+
# Run `ameba --only Lint/NotNil` for details
8+
Lint/NotNil:
9+
Description: Identifies usage of `not_nil!` calls
10+
Excluded:
11+
- spec/instrumentation/crystal_http_websocket_spec.cr
12+
- spec/instrumentation/stefanwille_redis_spec.cr
13+
- src/opentelemetry/instrumentation/crystal/http_server.cr
14+
- src/opentelemetry/instrumentation/crystal/http_client.cr
15+
Enabled: false
16+
Severity: Warning

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.1
1+
0.5.2

shard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: opentelemetry-instrumentation
2-
version: 0.5.1
2+
version: 0.5.2
33

44
authors:
55
- Kirk Haines <wyhaines@gmail.com>
@@ -19,7 +19,7 @@ dependencies:
1919
development_dependencies:
2020
ameba:
2121
github: crystal-ameba/ameba
22-
version: ~> 1.0.0
22+
version: ~> 1.4.3
2323
sqlite3:
2424
github: crystal-lang/crystal-sqlite3
2525
# Only one of these can be enabled, since they sit in the exact same namespace.

spec/instrumentation/crystal_log_spec.cr

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@ describe Log, tags: "Log" do
1616

1717
it "can log as normal and send attach the log as an event to a span" do
1818
checkout_config do
19-
memory = IO::Memory.new
20-
OpenTelemetry.configure do |config|
21-
config.service_name = "Crystal OTel Instrumentation - HTTP::Server"
22-
config.service_version = "1.0.0"
23-
config.exporter = OpenTelemetry::Exporter.new(variant: :io, io: memory)
24-
end
25-
backend = Log::MemoryBackend.new
26-
message = "I am a message, and there is an active span."
27-
Log.setup(:info, backend)
19+
memory = IO::Memory.new
20+
OpenTelemetry.configure do |config|
21+
config.service_name = "Crystal OTel Instrumentation - HTTP::Server"
22+
config.service_version = "1.0.0"
23+
config.exporter = OpenTelemetry::Exporter.new(variant: :io, io: memory)
24+
end
25+
backend = Log::MemoryBackend.new
26+
message = "I am a message, and there is an active span."
27+
Log.setup(:info, backend)
2828

29-
OpenTelemetry.trace.in_span("logging test span") do |_span|
30-
Log.info { message }
31-
end
29+
OpenTelemetry.trace.in_span("logging test span") do |_span|
30+
Log.info { message }
31+
end
3232

33-
backend.entries.first.message.should eq message
34-
_client_traces, server_traces = FindJson.from_io(memory)
35-
server_traces[0]["spans"][0]["name"].should eq "logging test span"
36-
server_traces[0]["spans"][0]["events"].size.should be > 0
37-
server_traces[0]["spans"][0]["events"][0]["name"].should eq "Log.INFO"
38-
server_traces[0]["spans"][0]["events"][0]["attributes"]["message"].as_s.should contain(message)
33+
backend.entries.first.message.should eq message
34+
_client_traces, server_traces = FindJson.from_io(memory)
35+
server_traces[0]["spans"][0]["name"].should eq "logging test span"
36+
server_traces[0]["spans"][0]["events"].size.should be > 0
37+
server_traces[0]["spans"][0]["events"][0]["name"].should eq "Log.INFO"
38+
server_traces[0]["spans"][0]["events"][0]["attributes"]["message"].as_s.should contain(message)
39+
end
3940
end
4041
end
41-
end

spec/instrumentation/websocket_spec_helper.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "../spec_helper"
22
require "../support/fibers"
33

4-
private def wait_for(timeout = 5.seconds)
4+
private def wait_for(timeout = 5.seconds, &)
55
now = Time.monotonic
66

77
until yield
@@ -22,7 +22,7 @@ end
2222
# shut down before continuing execution in the current fiber.
2323
# 6. If the listening fiber raises an exception, it is rescued and re-raised
2424
# in the current fiber.
25-
def run_server(server)
25+
def run_server(server, &)
2626
server_done = Channel(Exception?).new
2727

2828
f = spawn do
@@ -49,7 +49,7 @@ end
4949

5050
# Helper method which runs a *handler*
5151
# Similar to `run_server` but doesn't go through the network stack.
52-
def run_handler(handler)
52+
def run_handler(handler, &)
5353
done = Channel(Exception?).new
5454

5555
begin

spec/spec_helper.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def clear_env
1616
end
1717
end
1818

19-
def checkout_config(clear : Bool = true)
19+
def checkout_config(clear : Bool = true, &)
2020
config = OpenTelemetry.config
2121
clear_env if clear
2222
yield

src/opentelemetry-instrumentation/log_backend.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class OpenTelemetry::Instrumentation::LogBackend < ::Log::Backend
4242
end
4343

4444
def write(entry : ::Log::Entry)
45-
if (span = OpenTelemetry::Trace.current_span)
45+
if span = OpenTelemetry::Trace.current_span
4646
span.add_event("Log.#{entry.severity.label}#{" - #{entry.source}" unless entry.source.empty?}") do |event|
4747
self.class.apply_log_entry(entry, event)
4848
end

0 commit comments

Comments
 (0)