Skip to content

Commit 7debb92

Browse files
committed
Merge pull request #33 from amco/1.0
Create 1.0.0 release
2 parents 6751532 + 7c7fe85 commit 7debb92

27 files changed

+902
-195
lines changed

CHANGELOG.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,94 @@
1+
### Version 1.0.0
2+
3+
This is a major revision which means **APIs will break**. It is not backwards compatible with 0.1.x releases. Code from 0.1.x branches will no longer be supported. Please update!
4+
5+
#### Demo Project
6+
7+
* Added descriptions and examples on how to use various features to demo project
8+
9+
#### Metrics
10+
11+
* Added `metricNamed:valued:` to `LibratoMetric` (https://github.com/amco/librato-iOS/commit/0e10150892820ab7185bbd7752a2ec564d0cc458)
12+
* Added `metricNamed:valued:source:measureTime:` to `LibratoMetric` (https://github.com/amco/librato-iOS/commit/0e10150892820ab7185bbd7752a2ec564d0cc458)
13+
* Fixed `metricTime` not being set when passed in via `metricNamed:valued:options:` (https://github.com/amco/librato-iOS/commit/0e10150892820ab7185bbd7752a2ec564d0cc458)
14+
* Changed metrics to extend Mantle instead of `NSObject` (https://github.com/amco/librato-iOS/commit/e418ff7c1dd824c55529d0588ae6677a5a4b7062)
15+
* Changed `isValidValue` from instance to class method
16+
* Changed maximum metric age from one year to fifteen minutes (Librato Metric rules) (https://github.com/amco/librato-iOS/commit/53fbe0bee6a22e34b698f212d01a188ea40b9468)
17+
* Added automatic collection of device, OS, app and Librato library metrics when a `Librato` instance is initialized (https://github.com/amco/librato-iOS/commit/5ce4d5d16b49dd5a09e21c5e09eb48881157c0d4)
18+
* Fixed `LibratoClient.metrics` to report queued metrics instead of blank `NSDictionary`
19+
* Fixed queue firing `removeAllObjects` when `clear`ing instead of overwriting with new `NSMutableDictonary` so dictionary children are `release`d. (https://github.com/amco/librato-iOS/commit/704c245a1710ac6989d13d8b54d50d24206d8c53)
20+
21+
#### Collections
22+
23+
* Added `LibratoMetricCollection` which contains metrics based on type and handles conversion of metrics into structured JSON (https://github.com/amco/librato-iOS/commit/704c245a1710ac6989d13d8b54d50d24206d8c53)
24+
25+
#### Initialization
26+
27+
* Added `NSAsserts` in Librato, LibratoMetric and LibratoGaugeMetric `init` to disable use in favor of their custom initialization methods (https://github.com/amco/librato-iOS/commit/ebc4dcd5ed976607f1e13acff5cdaa9fdcf26adb)
28+
29+
#### Submission
30+
31+
* Added `add:` interface which is preferred over `submit:`
32+
* Changed manual submission to an optional command as queues are automatically submitted on a configurable interval (https://github.com/amco/librato-iOS/commit/fda9cbaeaa4525e61bff0c53932d94b2a6c47190)
33+
* Added global block handlers for submission success and failure (https://github.com/amco/librato-iOS/commit/e3e095cb26579446400e9ac61a33fb9e940ef8da)
34+
* Changed queue to clear just before firing submission instead of after successful submission to prevent accidental double submission (https://github.com/amco/librato-iOS/commit/5ce4d5d16b49dd5a09e21c5e09eb48881157c0d4)
35+
* Note: Queue is not cached before clearing, would could be useful if submission fails to re-queue items
36+
37+
#### Offline
38+
39+
* Added prevention of metrics submission if device is offline (https://github.com/amco/librato-iOS/commit/704c245a1710ac6989d13d8b54d50d24206d8c53)
40+
* Added automatic queue submission when internet becomes available
41+
* Added storage of queue in `NSKeyedArchiver` when app is backgrounded
42+
* Added queue hydration via `NSKeyedArchiver` when app is brought to foreground
43+
44+
#### Group metrics
45+
46+
* Added `groupNamed:valued:` to convert an `NSDictionary` into an array of `LibratoMetric`s (https://github.com/amco/librato-iOS/commit/fa4a9a5cf525e6ed04192e41b8bb709e57612a57)
47+
* Added `groupNamed:context:` to automatically prefix any metrics created in the context with the group name
48+
49+
#### Notification subscription
50+
51+
* Added ability of `Librato` to subscribe to notifications with `listenForNotification:context:` and perform given `context` when notification is caught (https://github.com/amco/librato-iOS/commit/4a7b5a974263b596bdaa1e74943c36d586b93f51)
52+
* Added queue specific to Librato subscriptions for `dispatch_async`ing execution of assigned `context`
53+
54+
#### User agent
55+
56+
* Added custom user agent setting available in `Librato` (https://github.com/amco/librato-iOS/commit/24e9edbc8dc03546fb8976239503a4c3ce3aab52)
57+
* Removed `agentIdentifier` from `LibratoClient`
58+
59+
#### Descriptions
60+
61+
* Added custom descriptions for Librato, LibratoClient, LibratoMetric, LibratoMetricCollection and LibratoQueue to aid debugging (https://github.com/amco/librato-iOS/commit/704c245a1710ac6989d13d8b54d50d24206d8c53)
62+
63+
#### Miscellaneous
64+
65+
* Removed numerous `NSLog`s. Sorry about the extra noise. (https://github.com/amco/librato-iOS/commit/474fe9a115ffe308eb2e858a93af0453568e76ad, https://github.com/amco/librato-iOS/commit/7433254602cdc3d3b6d9b755766a929b82d73805)
66+
167
### Version 0.1.0
268

3-
* Initial commit and functionality
69+
Initial commit and functionality
70+
71+
* Code available via CocoaPods
72+
73+
#### Metrics
74+
75+
* Create counter metric
76+
* Create group metric, statistics automatically computed
77+
* Name and source fields automatically cleaned and trimmed
78+
* Custom prefix available to be applied to all metric names
79+
* Values for all fields can be manipulated after initialization
80+
81+
#### Submission
82+
83+
* Metric types offered but `NSDictionary` data automatically parsed into appropriate Metric type and queued
84+
* Metrics only queued until manual submission
85+
* Only available parser is direct JSON parsing
86+
87+
#### Queue
88+
89+
* Add-only, no management
90+
* Manual submission
91+
92+
#### Localization
93+
94+
* Error messages localized for English

Demo/librato-iOS Demo.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@
334334
isa = XCBuildConfiguration;
335335
buildSettings = {
336336
ALWAYS_SEARCH_USER_PATHS = NO;
337-
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
337+
ARCHS = "$(ARCHS_STANDARD)";
338338
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
339339
CLANG_CXX_LIBRARY = "libc++";
340340
CLANG_ENABLE_MODULES = YES;
@@ -363,7 +363,7 @@
363363
GCC_WARN_UNINITIALIZED_AUTOS = YES;
364364
GCC_WARN_UNUSED_FUNCTION = YES;
365365
GCC_WARN_UNUSED_VARIABLE = YES;
366-
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
366+
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
367367
ONLY_ACTIVE_ARCH = YES;
368368
SDKROOT = iphoneos;
369369
TARGETED_DEVICE_FAMILY = "1,2";
@@ -374,7 +374,7 @@
374374
isa = XCBuildConfiguration;
375375
buildSettings = {
376376
ALWAYS_SEARCH_USER_PATHS = NO;
377-
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
377+
ARCHS = "$(ARCHS_STANDARD)";
378378
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
379379
CLANG_CXX_LIBRARY = "libc++";
380380
CLANG_ENABLE_MODULES = YES;
@@ -397,7 +397,7 @@
397397
GCC_WARN_UNINITIALIZED_AUTOS = YES;
398398
GCC_WARN_UNUSED_FUNCTION = YES;
399399
GCC_WARN_UNUSED_VARIABLE = YES;
400-
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
400+
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
401401
SDKROOT = iphoneos;
402402
TARGETED_DEVICE_FAMILY = "1,2";
403403
VALIDATE_PRODUCT = YES;

Demo/librato-iOS Demo/LibratoDemoAppDelegate.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2525
[eventTracker groupDictionaryExample];
2626
[eventTracker groupContextExample];
2727
[eventTracker gaugeMetricExample];
28+
[eventTracker notificationExample];
29+
[eventTracker metricCreationHelpersExample];
30+
[eventTracker customUAExample];
31+
[eventTracker submissionBlocksExample];
2832

2933
return YES;
3034
}

Demo/librato-iOS Demo/LibratoDemoEventTracker.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@
2222
- (void)groupDictionaryExample;
2323
- (void)groupContextExample;
2424
- (void)gaugeMetricExample;
25+
- (void)notificationExample;
26+
- (void)customUAExample;
27+
- (void)metricCreationHelpersExample;
28+
- (void)submissionBlocksExample;
2529

2630
@end

Demo/librato-iOS Demo/LibratoDemoEventTracker.m

Lines changed: 81 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,30 @@ + (Librato *)sharedInstance
4949
- (void)counterMetricExample
5050
{
5151
LibratoMetric *simpleMetric = [LibratoMetric metricNamed:@"works" valued:self.randomNumber options:@{@"source": @"demo app"}];
52-
simpleMetric.measureTime = [NSDate dateWithTimeIntervalSinceNow:-(3600 * 24)];
52+
simpleMetric.measureTime = [NSDate dateWithTimeIntervalSinceNow:-(60*5)];
5353

54-
NSLog(@"%@", simpleMetric);
55-
56-
[LibratoDemoEventTracker.sharedInstance submit:simpleMetric];
54+
[LibratoDemoEventTracker.sharedInstance add:simpleMetric];
5755
}
5856

5957

6058
/*
61-
Creates two different metrics but submits them simultaneously
59+
Creates two different metrics but adds them simultaneously
6260
*/
6361
- (void)multipleMetricSubmissionExample
6462
{
6563
LibratoMetric *memoryMetric = [LibratoMetric metricNamed:@"memory.available" valued:self.randomNumber options:nil];
6664
LibratoMetric *storageMetric = [LibratoMetric metricNamed:@"storage.available" valued:self.randomNumber options:nil];
6765

68-
NSLog(@"%@", memoryMetric);
69-
NSLog(@"%@", storageMetric);
70-
71-
[LibratoDemoEventTracker.sharedInstance submit:@[memoryMetric, storageMetric]];
66+
[LibratoDemoEventTracker.sharedInstance add:@[memoryMetric, storageMetric]];
7267
}
7368

7469

7570
/*
76-
Creates and auto-submits two counter metrics: "meaning" and "plutonium", the latter using an NSDictionary to set the value and source simultaneously
71+
Creates two counter metrics: "meaning" and "plutonium", the latter using an NSDictionary to set the value and source simultaneously
7772
*/
7873
- (void)dictionaryCreationExample
7974
{
80-
[LibratoDemoEventTracker.sharedInstance submit:@{@"meaning": self.randomNumber, @"plutonium": @{@"value": @238, @"source": @"Russia, with love"}}];
75+
[LibratoDemoEventTracker.sharedInstance add:@{@"meaning": self.randomNumber, @"plutonium": @{@"value": @238, @"source": @"Russia, with love"}}];
8176
}
8277

8378

@@ -89,7 +84,7 @@ - (void)dictionaryCreationExample
8984
The group prefix is the first argument and is joined to each metric named with a period.
9085
The dictionary's key value is the metric name as an NSString and the value is an NSNumber value.
9186
92-
If the group is named "foo" and the first metric is named "bar" it will be submitted with the name "foo.bar"
87+
If the group is named "foo" and the first metric is named "bar" it metric's submitted name will be "foo.bar"
9388
*/
9489
- (void)groupDictionaryExample
9590
{
@@ -99,7 +94,7 @@ - (void)groupDictionaryExample
9994
@"friends": @172
10095
};
10196
NSArray *metrics = [LibratoDemoEventTracker.sharedInstance groupNamed:@"user" valued:valueDict];
102-
[LibratoDemoEventTracker.sharedInstance submit:metrics];
97+
[LibratoDemoEventTracker.sharedInstance add:metrics];
10398
}
10499

105100

@@ -112,13 +107,38 @@ - (void)groupContextExample
112107
LibratoMetric *logins = [LibratoMetric metricNamed:@"logins" valued:@12 options:nil];
113108
LibratoMetric *logouts = [LibratoMetric metricNamed:@"logouts" valued:@7 options:nil];
114109
LibratoMetric *timeouts = [LibratoMetric metricNamed:@"timeouts" valued:@5 options:nil];
115-
[l submit:@[logins, logouts, timeouts]];
110+
[l add:@[logins, logouts, timeouts]];
116111
}];
117112
}
118113

119114

120115
/*
121-
Creates a series of counter measurements and submits them as a gague metric
116+
Provide the name of a notification and that notification will come into the block's context when it's caught.
117+
Contexts are executed asynchronously in a Librato-specific serial queue.
118+
A subscription with block is used and returned so you're responsible for unsubscribing when appropriate!
119+
*/
120+
- (void)notificationExample
121+
{
122+
__weak Librato *weakDemo = LibratoDemoEventTracker.sharedInstance;
123+
id subscription = [LibratoDemoEventTracker.sharedInstance listenForNotification:@"state.sleeping" context:^(NSNotification *notification) {
124+
LibratoMetric *useName = [LibratoMetric metricNamed:notification.name valued:@100 options:nil];
125+
LibratoMetric *useInfo = [LibratoMetric metricNamed:notification.userInfo[@"name"] valued:notification.userInfo[@"value"] options:notification.userInfo];
126+
127+
[weakDemo add:@[useName, useInfo]];
128+
}];
129+
130+
[NSNotificationCenter.defaultCenter postNotificationName:@"state.sleeping" object:nil userInfo:@{
131+
@"name": @"infoName",
132+
@"value": @42
133+
}];
134+
135+
// Don't forget to remove your subscriptions when you're done lest they hang around and point to a nil object!
136+
[NSNotificationCenter.defaultCenter removeObserver:subscription];
137+
}
138+
139+
140+
/*
141+
Creates a series of counter measurements and adds them as a gague metric
122142
*/
123143
- (void)gaugeMetricExample
124144
{
@@ -132,10 +152,54 @@ - (void)gaugeMetricExample
132152
LibratoMetric *metric8 = [LibratoMetric metricNamed:@"bagels" valued:@0 options:nil];
133153

134154
NSArray *bagels = @[metric1, metric2, metric3, metric4, metric5, metric6, metric7, metric8];
135-
NSLog(@"%@", bagels);
136155
LibratoGaugeMetric *bagelGuage = [LibratoGaugeMetric metricNamed:@"bagel_guage" measurements:bagels];
137156

138-
[LibratoDemoEventTracker.sharedInstance submit:bagelGuage];
157+
[LibratoDemoEventTracker.sharedInstance add:bagelGuage];
158+
}
159+
160+
161+
/*
162+
You can add a custom string the User Agent sent with all of the Librato requests
163+
WARNING: Setting a custom UA will reset your client's connection so do not do this arbitrarily
164+
*/
165+
- (void)customUAExample
166+
{
167+
Librato *l = LibratoDemoEventTracker.sharedInstance;
168+
l.customUserAgent = @"Demo UA";
169+
170+
[l add:@{@"ua.custom.instances": @1}];
171+
}
172+
173+
174+
/*
175+
Metrics can be created with increasing levels of specificity
176+
There are helpers for simple name & value metrics all the way up to all arguments specified
177+
*/
178+
- (void)metricCreationHelpersExample
179+
{
180+
LibratoMetric *basic = [LibratoMetric metricNamed:@"basic" valued:@1];
181+
LibratoMetric *explicit = [LibratoMetric metricNamed:@"explicit" valued:@100 source:@"demo" measureTime:NSDate.date];
182+
LibratoMetric *custom = [LibratoMetric metricNamed:@"custom" valued:@50 options:@{@"source": @"demo"}];
183+
184+
[LibratoDemoEventTracker.sharedInstance add:@[basic, explicit, custom]];
185+
}
186+
187+
188+
- (void)submissionBlocksExample
189+
{
190+
Librato *libratoInstance = LibratoDemoEventTracker.sharedInstance;
191+
192+
[libratoInstance setSubmitSuccessBlock:^(NSDictionary *JSON, NSUInteger code) {
193+
if (code == 200) {
194+
NSLog(@"Successful submission. Response JSON is: %@", JSON);
195+
}
196+
}];
197+
198+
[libratoInstance setSubmitFailureBlock:^(NSError *error, NSDictionary *JSON) {
199+
NSLog(@"Error submitting metric: %@", error);
200+
}];
201+
202+
[libratoInstance add:[LibratoMetric metricNamed:@"callbacks.test" valued:@123]];
139203
}
140204

141205

Demo/librato-iOS Demo/librato-iOS Demo-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0</string>
20+
<string>1.0.0</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)