├── .gitignore ├── Cargo.toml ├── .travis.yml ├── opentracing-api ├── src │ ├── lib.rs │ ├── context.rs │ ├── field.rs │ └── tag.rs └── Cargo.toml ├── CONTRIBUTING.md ├── opentracing-mock ├── Cargo.toml └── src │ └── lib.rs ├── opentracing-noop ├── Cargo.toml └── src │ └── lib.rs ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | Cargo.lock 3 | 4 | target/ 5 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "opentracing-api", 4 | "opentracing-noop", 5 | "opentracing-mock" 6 | ] -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | rust: 3 | - stable 4 | - beta 5 | - nightly 6 | matrix: 7 | allow_failures: 8 | - rust: nightly 9 | -------------------------------------------------------------------------------- /opentracing-api/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc(html_root_url = "https://docs.rs/opentracing-api/0.1.0")] 2 | 3 | mod context; 4 | mod tag; 5 | mod field; 6 | 7 | pub use context::SpanContext; 8 | pub use tag::{ParseTagsError, Tags}; 9 | pub use field::{Fields, ParseFieldsError}; 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to OpenTracing 2 | 3 | If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request (on a branch other than `master` or `gh-pages`). 4 | 5 | 6 | ## License 7 | 8 | By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/opentracing/opentracing-java/blob/master/LICENSE 9 | 10 | All files are released with the Apache 2.0 license. 11 | -------------------------------------------------------------------------------- /opentracing-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "opentracing-api" 3 | version = "0.1.0" # remember to update html_root_url 4 | authors = ["The OpenTracing Developers"] 5 | license = "Apache-2.0" 6 | homepage = "http://opentracing.io" 7 | repository = "https://github.com/opentracing/opentracing-rust" 8 | description = "OpenTracing API for Rust" 9 | documentation = "https://docs.rs/opentracing-api" 10 | keywords = ["opentracing", "tracing"] 11 | 12 | [badges] 13 | maintenance = { status = "actively-developed" } -------------------------------------------------------------------------------- /opentracing-mock/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "opentracing-mock" 3 | version = "0.1.0" # remember to update html_root_url 4 | authors = ["The OpenTracing Developers"] 5 | license = "Apache-2.0" 6 | homepage = "http://opentracing.io" 7 | repository = "https://github.com/opentracing/opentracing-rust" 8 | description = "A OpenTracing Mock Tracer" 9 | documentation = "https://docs.rs/opentracing-mock" 10 | keywords = ["opentracing", "tracing"] 11 | 12 | [badges] 13 | maintenance = { status = "actively-developed" } 14 | 15 | [dependencies] 16 | opentracing-api = { path = "../opentracing-api" } -------------------------------------------------------------------------------- /opentracing-noop/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "opentracing-noop" 3 | version = "0.1.0" # remember to update html_root_url 4 | authors = ["The OpenTracing Developers"] 5 | license = "Apache-2.0" 6 | homepage = "http://opentracing.io" 7 | repository = "https://github.com/opentracing/opentracing-rust" 8 | description = "A OpenTracing Noop Tracer" 9 | documentation = "https://docs.rs/opentracing-noop" 10 | keywords = ["opentracing", "tracing"] 11 | 12 | [badges] 13 | maintenance = { status = "actively-developed" } 14 | 15 | [dependencies] 16 | opentracing-api = { path = "../opentracing-api" } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenTracing API for Rust 2 | 3 | This library provides API and utilities for using [OpenTracing](http://opentracing.io/) with [Rust](https://www.rust-lang.org). 4 | 5 | **Please note that this project is currently under initial development and experimental.** We appreciate feedback and encourage trying it out if you don't mind things breaking between releases. 6 | 7 | ## Required Reading 8 | 9 | In order to understand the Rust API, one must first be familiar with the [OpenTracing project](http://opentracing.io) and [terminology](http://opentracing.io/documentation/pages/spec.html) more specifically. 10 | 11 | ## License 12 | 13 | [Apache 2.0 License](./LICENSE). 14 | 15 | -------------------------------------------------------------------------------- /opentracing-noop/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate provides a simple and cheap "noop" implementation of the 2 | //! tracing API and all of its sub-components. 3 | #![doc(html_root_url = "https://docs.rs/opentracing-noop/0.1.0")] 4 | 5 | extern crate opentracing_api; 6 | 7 | use opentracing_api::SpanContext; 8 | use std::iter::{empty, Empty}; 9 | 10 | /// The `NoopSpanContext` just returns an empty iterator on 11 | /// baggage items and all of its associated content. 12 | pub struct NoopSpanContext {} 13 | 14 | impl Default for NoopSpanContext { 15 | fn default() -> Self { 16 | NoopSpanContext {} 17 | } 18 | } 19 | 20 | impl<'a> SpanContext<'a> for NoopSpanContext { 21 | type Iter = Empty<(&'a String, &'a String)>; 22 | 23 | fn baggage_items(&'a self) -> Self::Iter { 24 | empty() 25 | } 26 | } 27 | 28 | #[cfg(test)] 29 | mod tests { 30 | 31 | use super::NoopSpanContext; 32 | use opentracing_api::SpanContext; 33 | 34 | #[test] 35 | fn test_empty_baggage() { 36 | let ctx = NoopSpanContext::default(); 37 | assert_eq!(None, ctx.baggage_items().next()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /opentracing-mock/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate provides a mocking implementation of the tracing 2 | //! API, especially useful for testing. 3 | #![doc(html_root_url = "https://docs.rs/opentracing-mock/0.1.0")] 4 | 5 | extern crate opentracing_api; 6 | 7 | use opentracing_api::SpanContext; 8 | use std::collections::HashMap; 9 | use std::collections::hash_map::Iter as HashMapIter; 10 | 11 | pub struct MockSpanContext { 12 | baggage: HashMap, 13 | } 14 | 15 | impl MockSpanContext { 16 | /// Create a new `MockSpanContext` with the given baggage. 17 | pub fn new(baggage: HashMap) -> Self { 18 | MockSpanContext { baggage } 19 | } 20 | } 21 | 22 | impl<'a> SpanContext<'a> for MockSpanContext { 23 | type Iter = HashMapIter<'a, String, String>; 24 | 25 | fn baggage_items(&'a self) -> Self::Iter { 26 | self.baggage.iter() 27 | } 28 | } 29 | 30 | #[cfg(test)] 31 | mod tests { 32 | 33 | use super::MockSpanContext; 34 | use opentracing_api::SpanContext; 35 | use std::collections::HashMap; 36 | 37 | #[test] 38 | fn test_map_baggage() { 39 | let mut items = HashMap::new(); 40 | items.insert("key".into(), "value".into()); 41 | 42 | let ctx = MockSpanContext::new(items); 43 | let mut iter = ctx.baggage_items(); 44 | assert_eq!( 45 | Some((&String::from("key"), &String::from("value"))), 46 | iter.next() 47 | ); 48 | assert_eq!(None, iter.next()); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /opentracing-api/src/context.rs: -------------------------------------------------------------------------------- 1 | /// `SpanContext` represents Span state that must propagate to 2 | /// descendant Spans and across process boundaries. 3 | /// 4 | /// `SpanContext` is logically divided into two pieces: (1) the user-level "Baggage" that 5 | /// propagates across Span boundaries and (2) any Tracer-implementation-specific fields 6 | /// that are needed to identify or otherwise contextualize the associated Span instance 7 | /// (e.g., a `(trace_id, span_id, sampled)` tuple). 8 | pub trait SpanContext<'a> { 9 | /// Associated type defining how to iterate over baggage items. 10 | type Iter: Iterator; 11 | 12 | /// Iterate over baggage items. 13 | /// 14 | /// Baggage items are key/value pairs that are propagated from 15 | /// the associated `Span` throught the trace. 16 | fn baggage_items(&'a self) -> Self::Iter; 17 | } 18 | 19 | #[cfg(test)] 20 | mod tests { 21 | use std::collections::HashMap; 22 | use std::collections::hash_map::Iter as HashMapIter; 23 | use super::SpanContext; 24 | 25 | struct TestContext { 26 | items: HashMap, 27 | } 28 | 29 | impl<'a> SpanContext<'a> for TestContext { 30 | type Iter = HashMapIter<'a, String, String>; 31 | 32 | fn baggage_items(&'a self) -> Self::Iter { 33 | self.items.iter() 34 | } 35 | } 36 | 37 | #[test] 38 | fn get_items() { 39 | let mut items = HashMap::new(); 40 | items.insert("key".into(), "value".into()); 41 | let context = TestContext { items }; 42 | let items: Vec<(&String, &String)> = context.baggage_items().collect(); 43 | assert_eq!(items, [(&"key".into(), &"value".into())]) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /opentracing-api/src/field.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | use std::error::Error; 3 | use std::str::FromStr; 4 | 5 | const FIELD_ERROR_KIND: &str = "error.kind"; 6 | const FIELD_ERROR_OBJECT: &str = "error.object"; 7 | const FIELD_EVENT: &str = "event"; 8 | const FIELD_MESSAGE: &str = "message"; 9 | const FIELD_STACK: &str = "stack"; 10 | 11 | /// The following log fields are recommended for instrumentors who are trying to capture more 12 | /// information about a logged event. Tracers may expose additional features based on these 13 | /// standardized data points. 14 | #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] 15 | pub enum Fields { 16 | /// The type or "kind" of an error (only for event="error" logs). E.g., "Exception", "OSError". 17 | ErrorKind, 18 | /// The actual Throwable/Exception/Error object instance itself. 19 | ErrorObject, 20 | /// A stable identifier for some notable moment in the lifetime of a Span. For instance, a mutex 21 | /// lock acquisition or release or the sorts of lifetime events in a browser page load described 22 | /// in the Performance.timing specification. E.g., from Zipkin, "cs", "sr", "ss", or "cr". Or, 23 | /// more generally, "initialized" or "timed out". For errors, "error". 24 | Event, 25 | /// A concise, human-readable, one-line message explaining the event. E.g., "Could not connect 26 | /// to backend", "Cache invalidation succeeded". 27 | Message, 28 | /// A stack trace in platform-conventional format; may or may not pertain to an error. 29 | Stack, 30 | } 31 | 32 | impl Fields { 33 | /// Returns the string representation for the enum reference variant. 34 | pub fn as_str(&self) -> &'static str { 35 | match *self { 36 | Fields::ErrorKind => FIELD_ERROR_KIND, 37 | Fields::ErrorObject => FIELD_ERROR_OBJECT, 38 | Fields::Event => FIELD_EVENT, 39 | Fields::Message => FIELD_MESSAGE, 40 | Fields::Stack => FIELD_STACK, 41 | } 42 | } 43 | } 44 | 45 | impl fmt::Display for Fields { 46 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 47 | write!(f, "{}", self.as_str()) 48 | } 49 | } 50 | 51 | impl FromStr for Fields { 52 | type Err = ParseFieldsError; 53 | 54 | fn from_str(s: &str) -> Result { 55 | match s { 56 | FIELD_ERROR_KIND => Ok(Fields::ErrorKind), 57 | FIELD_ERROR_OBJECT => Ok(Fields::ErrorObject), 58 | FIELD_EVENT => Ok(Fields::Event), 59 | FIELD_MESSAGE => Ok(Fields::Message), 60 | FIELD_STACK => Ok(Fields::Stack), 61 | _ => Err(ParseFieldsError::UnknownField), 62 | } 63 | } 64 | } 65 | 66 | /// Describes errors which can happen while parsing into the `Fields` enum. 67 | #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] 68 | pub enum ParseFieldsError { 69 | /// The provided field is not known. 70 | UnknownField, 71 | } 72 | 73 | impl Error for ParseFieldsError { 74 | fn description(&self) -> &str { 75 | match *self { 76 | ParseFieldsError::UnknownField => "Unknown Field", 77 | } 78 | } 79 | 80 | fn cause(&self) -> Option<&Error> { 81 | None 82 | } 83 | } 84 | 85 | impl fmt::Display for ParseFieldsError { 86 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 87 | write!(f, "{}", self.description()) 88 | } 89 | } 90 | 91 | #[cfg(test)] 92 | mod tests { 93 | 94 | use super::*; 95 | 96 | #[test] 97 | fn test_field_as_str() { 98 | assert_eq!("error.kind", Fields::ErrorKind.as_str()); 99 | assert_eq!("error.object", Fields::ErrorObject.as_str()); 100 | assert_eq!("event", Fields::Event.as_str()); 101 | assert_eq!("message", Fields::Message.as_str()); 102 | assert_eq!("stack", Fields::Stack.as_str()); 103 | } 104 | 105 | #[test] 106 | fn test_field_as_string() { 107 | assert_eq!(String::from("error.kind"), Fields::ErrorKind.to_string()); 108 | } 109 | 110 | #[test] 111 | fn test_field_from_string() { 112 | assert_eq!(Ok(Fields::Event), Fields::from_str("event")); 113 | assert_eq!(Ok(Fields::Message), "message".parse()); 114 | assert_eq!( 115 | Err(ParseFieldsError::UnknownField), 116 | Fields::from_str("some_other_field") 117 | ); 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /opentracing-api/src/tag.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | use std::error::Error; 3 | use std::str::FromStr; 4 | 5 | const TAG_SPAN_KIND_CLIENT: &str = "client"; 6 | const TAG_SPAN_KIND_SERVER: &str = "server"; 7 | const TAG_SPAN_KIND_PRODUCER: &str = "producer"; 8 | const TAG_SPAN_KIND_CONSUMER: &str = "consumer"; 9 | const TAG_HTTP_URL: &str = "http.url"; 10 | const TAG_HTTP_STATUS_CODE: &str = "http.status_code"; 11 | const TAG_HTTP_METHOD: &str = "http.method"; 12 | const TAG_PEER_IPV4: &str = "peer.ipv4"; 13 | const TAG_PEER_IPV6: &str = "peer.ipv6"; 14 | const TAG_PEER_SERVICE: &str = "peer.service"; 15 | const TAG_PEER_HOSTNAME: &str = "peer.hostname"; 16 | const TAG_PEER_PORT: &str = "peer.port"; 17 | const TAG_SAMPLING_PRIORITY: &str = "sampling.priority"; 18 | const TAG_SPAN_KIND: &str = "span.kind"; 19 | const TAG_COMPONENT: &str = "component"; 20 | const TAG_ERROR: &str = "error"; 21 | const TAG_DB_TYPE: &str = "db.type"; 22 | const TAG_DB_INSTANCE: &str = "db.instance"; 23 | const TAG_DB_USER: &str = "db.user"; 24 | const TAG_DB_STATEMENT: &str = "db.statement"; 25 | const TAG_MSGBUS_DEST: &str = "message_bus.destination"; 26 | 27 | /// The following span tags are recommended for instrumentors who are trying to capture more 28 | /// semantic information about the spans. Tracers may expose additional features based on these 29 | /// standardized data points. Tag names follow a general structure of namespacing. 30 | /// 31 | /// See also [Semantic Conventions](https://github.com/opentracing/specification/blob/master/semantic_conventions.md) 32 | #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] 33 | pub enum Tags { 34 | /// A constant for setting the span kind to indicate that it represents a client span. 35 | SpanKindClient, 36 | /// A constant for setting the span kind to indicate that it represents a server span. 37 | SpanKindServer, 38 | /// A constant for setting the span kind to indicate that it represents a producer span, 39 | /// in a messaging scenario. 40 | SpanKindProducer, 41 | /// A constant for setting the span kind to indicate that it represents a consumer span, 42 | /// in a messaging scenario. 43 | SpanKindConsumer, 44 | /// HTTP_URL records the url of the incoming request. 45 | HttpUrl, 46 | /// HTTP_STATUS records the http status code of the response. 47 | HttpStatus, 48 | /// HTTP_METHOD records the http method. Case-insensitive. 49 | HttpMethod, 50 | /// PEER_HOST_IPV4 records IPv4 host address of the peer. 51 | PeerHostIpv4, 52 | /// PEER_HOST_IPV6 records the IPv6 host address of the peer. 53 | PeerHostIpv6, 54 | /// PEER_SERVICE records the service name of the peer. 55 | PeerService, 56 | /// PEER_HOSTNAME records the host name of the peer. 57 | PeerHostname, 58 | /// PEER_PORT records the port number of the peer. 59 | PeerPort, 60 | /// SAMPLING_PRIORITY determines the priority of sampling this Span. 61 | SamplingPriority, 62 | /// SPAN_KIND hints at the relationship between spans, e.g. client/server. 63 | SpanKind, 64 | /// COMPONENT is a low-cardinality identifier of the module, library, or 65 | /// package that is instrumented. 66 | Component, 67 | /// ERROR indicates whether a Span ended in an error state. 68 | Error, 69 | /// DB_TYPE indicates the type of Database. 70 | DbType, 71 | /// DB_INSTANCE indicates the instance name of Database. 72 | DbInstance, 73 | /// DB_USER indicates the user name of Database, e.g. "readonly_user" or 74 | /// "reporting_user" 75 | DbUser, 76 | /// DB_STATEMENT records a database statement for the given database type. 77 | DbStatement, 78 | /// MESSAGE_BUS_DESTINATION records an address at which messages can be 79 | /// exchanged. 80 | MessageBusDestination, 81 | } 82 | 83 | impl Tags { 84 | /// Returns the string representation for the enum reference variant. 85 | pub fn as_str(&self) -> &'static str { 86 | match *self { 87 | Tags::SpanKindClient => TAG_SPAN_KIND_CLIENT, 88 | Tags::SpanKindServer => TAG_SPAN_KIND_SERVER, 89 | Tags::SpanKindProducer => TAG_SPAN_KIND_PRODUCER, 90 | Tags::SpanKindConsumer => TAG_SPAN_KIND_CONSUMER, 91 | Tags::HttpUrl => TAG_HTTP_URL, 92 | Tags::HttpStatus => TAG_HTTP_STATUS_CODE, 93 | Tags::HttpMethod => TAG_HTTP_METHOD, 94 | Tags::PeerHostIpv4 => TAG_PEER_IPV4, 95 | Tags::PeerHostIpv6 => TAG_PEER_IPV6, 96 | Tags::PeerService => TAG_PEER_SERVICE, 97 | Tags::PeerHostname => TAG_PEER_HOSTNAME, 98 | Tags::PeerPort => TAG_PEER_PORT, 99 | Tags::SamplingPriority => TAG_SAMPLING_PRIORITY, 100 | Tags::SpanKind => TAG_SPAN_KIND, 101 | Tags::Component => TAG_COMPONENT, 102 | Tags::Error => TAG_ERROR, 103 | Tags::DbType => TAG_DB_TYPE, 104 | Tags::DbInstance => TAG_DB_INSTANCE, 105 | Tags::DbUser => TAG_DB_USER, 106 | Tags::DbStatement => TAG_DB_STATEMENT, 107 | Tags::MessageBusDestination => TAG_MSGBUS_DEST, 108 | } 109 | } 110 | } 111 | 112 | impl fmt::Display for Tags { 113 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 114 | write!(f, "{}", self.as_str()) 115 | } 116 | } 117 | 118 | impl FromStr for Tags { 119 | type Err = ParseTagsError; 120 | 121 | fn from_str(s: &str) -> Result { 122 | match s { 123 | TAG_SPAN_KIND_CLIENT => Ok(Tags::SpanKindClient), 124 | TAG_SPAN_KIND_SERVER => Ok(Tags::SpanKindServer), 125 | TAG_SPAN_KIND_PRODUCER => Ok(Tags::SpanKindProducer), 126 | TAG_SPAN_KIND_CONSUMER => Ok(Tags::SpanKindConsumer), 127 | TAG_HTTP_URL => Ok(Tags::HttpUrl), 128 | TAG_HTTP_STATUS_CODE => Ok(Tags::HttpStatus), 129 | TAG_HTTP_METHOD => Ok(Tags::HttpMethod), 130 | TAG_PEER_IPV4 => Ok(Tags::PeerHostIpv4), 131 | TAG_PEER_IPV6 => Ok(Tags::PeerHostIpv6), 132 | TAG_PEER_SERVICE => Ok(Tags::PeerService), 133 | TAG_PEER_HOSTNAME => Ok(Tags::PeerHostname), 134 | TAG_PEER_PORT => Ok(Tags::PeerPort), 135 | TAG_SAMPLING_PRIORITY => Ok(Tags::SamplingPriority), 136 | TAG_SPAN_KIND => Ok(Tags::SpanKind), 137 | TAG_COMPONENT => Ok(Tags::Component), 138 | TAG_ERROR => Ok(Tags::Error), 139 | TAG_DB_TYPE => Ok(Tags::DbType), 140 | TAG_DB_INSTANCE => Ok(Tags::DbInstance), 141 | TAG_DB_USER => Ok(Tags::DbUser), 142 | TAG_DB_STATEMENT => Ok(Tags::DbStatement), 143 | TAG_MSGBUS_DEST => Ok(Tags::MessageBusDestination), 144 | _ => Err(ParseTagsError::UnknownTag), 145 | } 146 | } 147 | } 148 | 149 | /// Describes errors which can happen while parsing into the `Tags` enum. 150 | #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] 151 | pub enum ParseTagsError { 152 | /// The provided tag is not known. 153 | UnknownTag, 154 | } 155 | 156 | impl Error for ParseTagsError { 157 | fn description(&self) -> &str { 158 | match *self { 159 | ParseTagsError::UnknownTag => "Unknown Tag", 160 | } 161 | } 162 | 163 | fn cause(&self) -> Option<&Error> { 164 | None 165 | } 166 | } 167 | 168 | impl fmt::Display for ParseTagsError { 169 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 170 | write!(f, "{}", self.description()) 171 | } 172 | } 173 | 174 | #[cfg(test)] 175 | mod tests { 176 | 177 | use super::*; 178 | 179 | #[test] 180 | fn test_tag_as_str() { 181 | assert_eq!("client", Tags::SpanKindClient.as_str()); 182 | } 183 | 184 | #[test] 185 | fn test_tag_as_string() { 186 | assert_eq!(String::from("client"), Tags::SpanKindClient.to_string()); 187 | } 188 | 189 | #[test] 190 | fn test_tag_from_string() { 191 | assert_eq!(Ok(Tags::Error), Tags::from_str("error")); 192 | assert_eq!(Ok(Tags::PeerHostIpv4), "peer.ipv4".parse()); 193 | assert_eq!( 194 | Err(ParseTagsError::UnknownTag), 195 | Tags::from_str("some_other_field") 196 | ); 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------